package cn.janyd.jmall.system.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

/**
 * 管理员状态
 *
 * @author janyd
 * @since 2020/8/14 21:08
 */
public enum AdminStatus {

    /**
     * 在职
     */
    ACTIVE(1, "在职"),

    /**
     * 离职
     */
    INACTIVE(2, "离职");

    @EnumValue
    private final Integer status;

    private final String name;

    AdminStatus(Integer status, String name) {
        this.status = status;
        this.name = name;
    }

    @JsonValue
    public Integer getStatus() {
        return status;
    }

    public String getName() {
        return name;
    }

    @JsonCreator
    public static AdminStatus parse(int value) {
        for (AdminStatus status : AdminStatus.values()) {
            if (status.getStatus() == value) {
                return status;
            }
        }

        throw new RuntimeException("AdminStatus 序列化失败");
    }
}
